From: Keir Fraser Date: Mon, 26 Nov 2007 17:54:54 +0000 (+0000) Subject: x86_emulate: Emulate LMSW and SMSW. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14684^2~19 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=70d9b1077f1a4586092851badeca60703b57eccf;p=xen.git x86_emulate: Emulate LMSW and SMSW. Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/x86_emulate.c b/xen/arch/x86/x86_emulate.c index 1397732a7f..763d73774f 100644 --- a/xen/arch/x86/x86_emulate.c +++ b/xen/arch/x86/x86_emulate.c @@ -2666,6 +2666,7 @@ x86_emulate( { case 0x01: /* Grp7 */ { struct segment_register reg; + unsigned long base, limit, cr0, cr0w; switch ( modrm_reg & 7 ) { @@ -2691,11 +2692,12 @@ x86_emulate( fail_if(ops->write_segment == NULL); memset(®, 0, sizeof(reg)); if ( (rc = ops->read(ea.mem.seg, ea.mem.off+0, - (unsigned long *)®.limit, 2, ctxt)) || + &limit, 2, ctxt)) || (rc = ops->read(ea.mem.seg, ea.mem.off+2, - (unsigned long *)®.base, - mode_64bit() ? 8 : 4, ctxt)) ) + &base, mode_64bit() ? 8 : 4, ctxt)) ) goto done; + reg.base = base; + reg.limit = limit; if ( op_bytes == 2 ) reg.base &= 0xffffff; if ( (rc = ops->write_segment((modrm_reg & 1) ? @@ -2703,6 +2705,29 @@ x86_emulate( ®, ctxt)) ) goto done; break; + case 4: /* smsw */ + dst = ea; + dst.bytes = 2; + fail_if(ops->read_cr == NULL); + if ( (rc = ops->read_cr(0, &dst.val, ctxt)) ) + goto done; + d |= Mov; /* force writeback */ + break; + case 6: /* lmsw */ + fail_if(ops->read_cr == NULL); + fail_if(ops->write_cr == NULL); + if ( (rc = ops->read_cr(0, &cr0, ctxt)) ) + goto done; + if ( ea.type == OP_REG ) + cr0w = *ea.reg; + else if ( (rc = ops->read(ea.mem.seg, ea.mem.off, + &cr0w, 2, ctxt)) ) + goto done; + cr0 &= 0xffff0000; + cr0 |= (uint16_t)cr0w; + if ( (rc = ops->write_cr(0, cr0, ctxt)) ) + goto done; + break; default: goto cannot_emulate; }